﻿package com.tudou.home.controller.ad
{
    import com.tudou.ad.consts.*;
    import com.tudou.ad.interfaces.*;
    import com.tudou.home.commands.*;
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.consts.*;
    import com.tudou.home.model.*;
    import com.tudou.home.model.ad.*;
    import com.tudou.home.view.*;
    import flash.geom.*;
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class AdBackCommand extends SimpleCommand
    {

        public function AdBackCommand()
        {
            return;
        }// end function

        private function adClear() : void
        {
            var _loc_1:* = facade.retrieveProxy(AdBackProxy.NAME) as AdBackProxy;
            var _loc_2:* = facade.retrieveMediator(SkinMediator.NAME) as SkinMediator;
            if (_loc_1.adItemInfo)
            {
                _loc_2.removeAdVideo();
                _loc_1.clearAd();
                sendNotification(ExternalCommandSet.REMOVE_AD_BACK);
                if (!PageInfo.getInstance().isListPlayer)
                {
                    sendNotification(PageCommandSet.LOAD_SHARE_RELATIVE_DATA);
                    sendNotification(PlayerCommandSet.SHOW_PLAY_COMPLETE);
                }
            }
            AdConsts.FRONT_AD_ING = false;
            return;
        }// end function

        override public function execute(param1:INotification) : void
        {
            var _loc_6:Rectangle = null;
            var _loc_2:* = facade.retrieveProxy(AdInfoProxy.NAME) as AdInfoProxy;
            var _loc_3:* = facade.retrieveProxy(AdBackProxy.NAME) as AdBackProxy;
            var _loc_4:* = facade.retrieveMediator(SkinMediator.NAME) as SkinMediator;
            var _loc_5:* = _loc_2.getCurrAdItemByType(AdType.BACK);
            var _loc_7:* = param1.getBody();
            var _loc_8:int = 0;
            switch(param1.getName())
            {
                case AdBackCommandSet.START:
                {
                    AdConsts.FRONT_AD_ING = true;
                    _loc_3.adItemInfo = _loc_5;
                    _loc_3.adThrowInfo = _loc_2.throwInfo;
                    _loc_3.startAd();
                    break;
                }
                case AdBackCommandSet.CLEAR:
                {
                    _loc_8 = AdModStatus.CLEAR;
                    break;
                }
                case AdBackCommandSet.START_PREPAREED:
                {
                    _loc_3.startAdBack();
                    break;
                }
                case ViewCommandSet.ENTER_FULLSCREEN_AND_RESIZE:
                {
                    _loc_6 = PlayerConsts.FULLSCREEN_RECT;
                    if (_loc_3)
                    {
                        _loc_3.goTransform(_loc_6.width, _loc_6.height, true);
                    }
                    break;
                }
                case ViewCommandSet.NORMALSCREEN_RESIZE:
                {
                    _loc_6 = PlayerConsts.NORMALSCREEN_RECT;
                    if (_loc_3)
                    {
                        _loc_3.goTransform(_loc_6.width, _loc_6.height, false);
                    }
                    break;
                }
                case ViewCommandSet.EXPAND_STAGE:
                {
                    if (_loc_3 && _loc_3.view)
                    {
                        _loc_3.view.isExpand = _loc_7;
                    }
                    break;
                }
                case AdBackCommandSet.ERROR_END:
                {
                    _loc_8 = AdModStatus.CLEAR;
                    break;
                }
                case AdBackCommandSet.PREPARE_TO_SHOW:
                {
                    _loc_3.startView();
                    if (_loc_3.view)
                    {
                        _loc_4.setAdVideo(_loc_3.view.adDisplay);
                    }
                    break;
                }
                case AdBackCommandSet.SHOW_START:
                {
                    break;
                }
                case AdBackCommandSet.SHOW_END:
                {
                    _loc_8 = AdModStatus.COMPLETE;
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            switch(_loc_8)
            {
                case AdModStatus.COMPLETE:
                case AdModStatus.CLEAR:
                {
                    adClear();
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

    }
}
